package com.jianxiu.web;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jianxiu.bean.BaseController;
import com.jianxiu.bean.Result;
import com.jianxiu.bean.User;
import com.jianxiu.service.UserService;

@Controller
@RequestMapping("user")
public class UserController extends BaseController {

    @Resource
    private UserService userService;

    @RequestMapping("register")
    @ResponseBody
    public Result register(HttpServletRequest request, String realname, String mobile) {
        User user = getSessionUser(request);
        if (user.isRegister()) return Result.byMsg("已注册");
        user.setMobile(mobile);
        user.setRealname(realname);
        user.setStatus(1);
        userService.update(user);
        setSessionUser(request, user);
        return Result.success();
    }
}
